package com.lineage.server.types;

public class UChar8 {
  public static char[] fromArray(long[] buff) {
    char[] charBuff = new char[buff.length * 4];
    int i = 0;
    while (i < buff.length) {
      charBuff[i * 4 + 0] = (char)(int)(buff[i] & 0xFFL);
      charBuff[i * 4 + 1] = (char)(int)(buff[i] >> 8L & 0xFFL);
      charBuff[i * 4 + 2] = (char)(int)(buff[i] >> 16L & 0xFFL);
      charBuff[i * 4 + 3] = (char)(int)(buff[i] >> 24L & 0xFFL);
      i++;
    } 
    return charBuff;
  }
  
  public static char[] fromArray(byte[] buff) {
    char[] charBuff = new char[buff.length];
    int i = 0;
    while (i < buff.length) {
      charBuff[i] = (char)(buff[i] & 0xFF);
      i++;
    } 
    return charBuff;
  }
  
  public static char[] fromArray(byte[] buff, int length) {
    char[] charBuff = new char[length];
    int i = 0;
    while (i < length) {
      charBuff[i] = (char)(buff[i] & 0xFF);
      i++;
    } 
    return charBuff;
  }
  
  public static char fromUByte8(byte b) {
    return (char)(b & 0xFF);
  }
  
  public static char[] fromULong32(long l) {
    char[] charBuff = { (char)(int)(l & 0xFFL), (char)(int)(l >> 8L & 0xFFL), 
        (char)(int)(l >> 16L & 0xFFL), (char)(int)(l >> 24L & 0xFFL) };
    return charBuff;
  }
}
